//
//  HMBaseTableViewController.swift
//  WymanWeibo
//
//  Created by wyman on 16/4/8.
//  Copyright © 2016年 wyman. All rights reserved.
//

import UIKit

class HMBaseTableViewController: UITableViewController{
    var userLogin = HMUserAccountViewModel.shareInstance.userLogin

    override func loadView() {
        userLogin ? super.loadView() : setupVisorView()
    }
    
    private func setupVisorView(){
//        view = tableViewnnnnnnnnnnnnnn 
        view = visitorView
        //判断是哪个控制器
        visitorView.delegate = self
        if self is HMHomeViewController {
//            visitorView.valueForKeyPath("iconView.hidden")
            
           visitorView.startRoutate()
            
        }else if self is HMMessageViewController{
        visitorView.setupVistorViewInfo("visitordiscover_image_message", message:  "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        }else if self is HMDiscoverViewController{
        
        visitorView.setupVistorViewInfo("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            
        }else if self is HMProfileViewController{
            
            visitorView.setupVistorViewInfo("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")

        }
        //设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: Selector("visitorViewDidClickRegisterButton"))
        
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: Selector("visitorViewDidClickLoginButton"))
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    //用户是否登录
        
     
    }

 
    lazy var visitorView: HMVistorView = HMVistorView()

}
//MARK: - 类的扩展
extension HMBaseTableViewController: HMVistorViewDelegate
{

    func visitorViewDidClickRegisterButton() {
        HMPrint("注册啦")
    }
    
    func visitorViewDidClickLoginButton() {
     //弹出窗口
        let naVc = HMQauthViewController()
        
        self.presentViewController(UINavigationController(rootViewController: naVc), animated: true, completion: nil)
    }




}











